﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="MyGMaps._Default"
    ValidateRequest="false" %>

<%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>
<%@ Register Src="GoogleMapForASPNet.ascx" TagName="GoogleMapForASPNet" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>My Google Map</title>
    <link href="C1.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .login
        {
            width: 349px;
        }
        .passwordEntry
        {
        }
        .textEntry
        {
        }
        .style1
        {
            width: 113px;
        }
    </style>
    <script type="text/javascript">
        function getPos() {
            if (navigator.geolocation) {
                // Use method getCurrentPosition to get coordinates
                navigator.geolocation.getCurrentPosition(function (position) {
                    // Access them accordingly
                    document.getElementById('<%= hdTempLat.ClientID %>').value = position.coords.latitude;
                    document.getElementById('<%= hdTempLng.ClientID %>').value = position.coords.longitude;
                });
            }
        }
        window.onload = getPos;
    </script>
</head>
<body>
    <form id="form1" defaultbutton="btnSearch" runat="server">
    <input type="hidden" id="hdTempLat" runat="server" />
    <input type="hidden" id="hdTempLng" runat="server" />
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div id="Login">
        <asp:Label ID="Label1" runat="server" Text="Username:" Font-Names="Times New Roman"></asp:Label>
        <asp:TextBox ID="tbx_Username" runat="server" BackColor="#FFFF99" Font-Names="Times New Roman"></asp:TextBox>
        &nbsp;&nbsp;
        <asp:Label ID="Label2" runat="server" Text="Pass:" Font-Names="Times New Roman"></asp:Label>
        <asp:TextBox ID="tbx_Pass" runat="server" BackColor="#FFFF99" TextMode="Password"
            Font-Names="Times New Roman">password</asp:TextBox>
        &nbsp;&nbsp;&nbsp;
        <asp:Button ID="btn_DangNhap" runat="server" OnClick="btn_DangNhap_Click" Text="Đăng nhập"
            Font-Names="Times New Roman" />
        &nbsp;<asp:Button ID="btn_DangXuat" runat="server" Text="Đăng Xuất" Font-Names="Times New Roman"
            OnClick="btn_DangXuat_Click" />
        &nbsp;&nbsp;&nbsp;
        <asp:Label ID="lbl_Alert" runat="server" Font-Names="Times New Roman" Style="text-align: left"
            Width="300px"></asp:Label>
    </div>
    <br />
    <div id="Main_Search">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <div id="Search">
                    <table>
                        <tr>
                            <td>
                                <asp:TextBox ID="TextSearch" runat="server" BorderColor="#4B8DFA" Width="509px" Height="22px"
                                    Style="margin-left: 11px"></asp:TextBox>
                            </td>
                            <td>
                                <asp:ImageButton ID="btnSearch" ImageUrl="PIC/Searchbnt.png" runat="server" ToolTip="Tìm kiếm"
                                    OnClick="btnSearch_Click" Height="27px" />
                            </td>
                            <td>
                                <asp:ImageButton ID="ibt_MyLocation" ImageUrl="PIC/bntlocation.png" ToolTip="Vị trí của bạn"
                                    runat="server" Height="27px" OnClick="ibt_MyLocation_Click" />
                            </td>
                            <td>
                            </td>
                            <td>
                                <asp:ImageButton ID="ibt_FindNearService" ImageUrl="PIC/btnservice.jpg" ToolTip="Tìm dịch vụ gần nhất"
                                    runat="server" OnClick="ibt_FindNearService_Click" Height="27px" />
                            </td>
                        </tr>
                    </table>
                </div>
                <br />
                <div id="info">
                    <div id="marquee">
                        <marquee direction="left" behavior="alternate" scrollamount="20">Thông Tin Địa Điểm</marquee>
                    </div>
                    <table width="280px">
                        <tr>
                            <td class="style1">
                                Loại dịch vụ:
                            </td>
                            <td>
                                <asp:DropDownList ID="ddl_LDV" BorderColor="#4B8DFA" runat="server" AppendDataBoundItems="True"
                                    DataSourceID="ADS_LoaiDichVu" DataTextField="DichVu" DataValueField="DichVu">
                                </asp:DropDownList>
                            </td>
                        </tr>
                        <tr>
                            <td class="style1">
                                Tên địa điểm:
                            </td>
                            <td>
                                <asp:TextBox ID="tbx_TenDichVu" BorderColor="#4B8DFA" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td class="style1">
                                Vĩ độ:
                            </td>
                            <td>
                                <asp:TextBox ID="tbx_ViDo" BorderColor="#4B8DFA" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td class="style1">
                                Tung độ:
                            </td>
                            <td>
                                <asp:TextBox ID="tbx_TungDo" BorderColor="#4B8DFA" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                         <tr>
                            <td colspan="2" align="center">
                                <asp:CheckBox ID="Share" Text="Share" runat="server" />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" align="right">
                                <asp:Button ID="Update" runat="server" Text="Cập Nhật" OnClick="Update_Click" />
                                &nbsp
                                <asp:Button ID="Save" runat="server" Text="Lưu" OnClick="Save_Click" />
                                &nbsp
                                <asp:Button ID="btn_Xoa" runat="server" Text="Xóa" OnClick="btn_Xoa_Click" />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <asp:Label ID="lbl_ThongBao" runat="server" ForeColor="OrangeRed"></asp:Label>
                                &nbsp
                            </td>
                        </tr>
                    </table>
                    <table>
                    </table>
                    <hr />
                    <div>
                        <asp:Label ID="Label3" runat="server" Text="Loại Dịch Vụ:"></asp:Label>
                        &nbsp;<asp:DropDownList ID="ddl_LoaiDichVu" runat="server" AutoPostBack="True" DataSourceID="ADS_LoaiDichVu"
                            DataTextField="DichVu" DataValueField="DichVu">
                        </asp:DropDownList>
                        <asp:GridView ID="grw_DanhSachDiaDiem" runat="server" AutoGenerateColumns="False"
                            DataKeyNames="PointID" DataSourceID="ADS_DanhSachDiaDiem" EnableModelValidation="True"
                            OnRowCommand="grw_DanhSachDiaDiem_RowCommand" AllowSorting="True" Height="86px"
                            Width="300px">
                            <AlternatingRowStyle BackColor="White" />
                            <Columns>
                                <asp:BoundField DataField="PointID" HeaderText="PointID" SortExpression="PointID"
                                    InsertVisible="False" ReadOnly="True">
                                    <ItemStyle Width="50px" />
                                </asp:BoundField>
                                <asp:BoundField DataField="Username" HeaderText="Username" SortExpression="Username"
                                    Visible="False" />
                                <asp:BoundField DataField="DichVu" HeaderText="Dịch Vụ" SortExpression="DichVu" 
                                    Visible="False" />
                                <asp:BoundField DataField="TenDichVu" HeaderText="Tên Dịch Vụ" SortExpression="TenDichVu" />
                                <asp:BoundField DataField="ViDo" HeaderText="Vĩ Độ" SortExpression="ViDo" />
                                <asp:BoundField DataField="TungDo" HeaderText="Tung Độ" SortExpression="TungDo" />
                                <asp:ButtonField CommandName="Select" HeaderText="Chi Tiết" Text="Hiển Thị" />
                                <asp:CommandField HeaderText="Tùy Chọn" ShowDeleteButton="True" />
                            </Columns>
                            <EditRowStyle BackColor="#7C6F57" />
                            <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                            <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                            <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
                            <RowStyle BackColor="#E3EAEB" />
                            <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
                        </asp:GridView>
                    </div>
                </div>
                <div id="SearchResult">
                    <asp:GridView ID="GridView1" runat="server" BackColor="White" BorderColor="#CCCCCC"
                        BorderStyle="None" BorderWidth="1px" CellPadding="4" EnableModelValidation="True"
                        ForeColor="Black" GridLines="Horizontal" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
                        <Columns>
                            <asp:CommandField ShowSelectButton="True" ButtonType="Image" SelectImageUrl="~/PIC/toolbx-icn-mp3.gif">
                                <ControlStyle ForeColor="#0033CC" />
                            </asp:CommandField>
                        </Columns>
                        <FooterStyle BackColor="#CCCC99" ForeColor="Black" />
                        <HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Right" />
                        <SelectedRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />
                    </asp:GridView>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    <uc1:GoogleMapForASPNet ID="GoogleMapForASPNet1" runat="server" />
    <br />
    <asp:AccessDataSource ID="ADS_LoaiDichVu" runat="server" DataFile="~/App_Data/GoogleMapService.mdb"
        SelectCommand="SELECT * FROM [DICHVU]"></asp:AccessDataSource>
    <br />
    <asp:AccessDataSource ID="ADS_TaiKhoan" runat="server" DataFile="~/App_Data/GoogleMapService.mdb"
        SelectCommand="SELECT * FROM [TAIKHOAN]"></asp:AccessDataSource>
    <br />
    <asp:AccessDataSource ID="ADS_DanhSachDiaDiem" runat="server" DataFile="~/App_Data/GoogleMapService.mdb"
        SelectCommand="SELECT * FROM [DIADIEM] WHERE (([DichVu] = ?) AND (([Username] = ?) OR ([Share] = 1)))"
        DeleteCommand="DELETE FROM [DIADIEM] WHERE [PointID] = ?" 
        InsertCommand="INSERT INTO [DIADIEM] ([Username], [DichVu], [TenDichVu], [ViDo], [TungDo], [Share]) VALUES (?, ?, ?, ?, ?, ?)"
        UpdateCommand="UPDATE [DIADIEM] SET [Username] = ?, [DichVu] = ?, [TenDichVu] = ?, [ViDo] = ?, [TungDo] = ?, [Share] = ? WHERE [PointID] = ?">
        <DeleteParameters>
            <asp:Parameter Name="PointID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="Username" Type="String" />
            <asp:Parameter Name="DichVu" Type="String" />
            <asp:Parameter Name="TenDichVu" Type="String" />
            <asp:Parameter Name="ViDo" Type="String" />
            <asp:Parameter Name="TungDo" Type="String" />
            <asp:Parameter Name="Share" Type="String" />
        </InsertParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="ddl_LoaiDichVu" Name="DichVu" PropertyName="SelectedValue"
                Type="String" />
            <asp:ControlParameter ControlID="tbx_Username" Name="Username" PropertyName="Text"
                Type="String" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="Username" Type="String" />
            <asp:Parameter Name="DichVu" Type="String" />
            <asp:Parameter Name="TenDichVu" Type="String" />
            <asp:Parameter Name="ViDo" Type="String" />
            <asp:Parameter Name="TungDo" Type="String" />
            <asp:Parameter Name="Share" Type="String" />
            <asp:Parameter Name="PointID" Type="Int32" />
        </UpdateParameters>
    </asp:AccessDataSource>
    <asp:AccessDataSource ID="ADS_DiaDiem" runat="server" 
        DataFile="~/App_Data/GoogleMapService.mdb" 
        DeleteCommand="DELETE FROM [DIADIEM] WHERE [PointID] = ?" 
        InsertCommand="INSERT INTO [DIADIEM] ([PointID], [Username], [DichVu], [TenDichVu], [ViDo], [TungDo], Share) VALUES (?, ?, ?, ?, ?, ?, ?)" 
        SelectCommand="SELECT * FROM [DIADIEM] WHERE ([Username] = ?) OR ([Share] = '1')"
        UpdateCommand="UPDATE [DIADIEM] SET [Username] = ?, [DichVu] = ?, [TenDichVu] = ?, [ViDo] = ?, [TungDo] = ?, [Share]= ? WHERE [PointID] = ?">
        <DeleteParameters>
            <asp:Parameter Name="PointID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="PointID" Type="Int32" />
            <asp:Parameter Name="Username" Type="String" />
            <asp:Parameter Name="DichVu" Type="String" />
            <asp:Parameter Name="TenDichVu" Type="String" />
            <asp:Parameter Name="ViDo" Type="String" />
            <asp:Parameter Name="TungDo" Type="String" />
            <asp:Parameter Name="Share" Type="String" />
        </InsertParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="tbx_Username" Name="Username" 
                PropertyName="Text" Type="String" />
           <asp:ControlParameter ControlID="Share" Name="Share" 
                PropertyName="Text" Type="String" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="Username" Type="String" />
            <asp:Parameter Name="DichVu" Type="String" />
            <asp:Parameter Name="TenDichVu" Type="String" />
            <asp:Parameter Name="ViDo" Type="String" />
            <asp:Parameter Name="TungDo" Type="String" />
            <asp:Parameter Name="Share" Type="String" />
            <asp:Parameter Name="PointID" Type="Int32" />
        </UpdateParameters>
    </asp:AccessDataSource>
    </form>
</body>
</html>
